package com.kd.spring.dao;

import org.springframework.jdbc.core.support.JdbcDaoSupport;
import org.springframework.stereotype.Repository;

import com.kd.spring.model.User;

@Repository("userDao")
public class UserDao extends JdbcDaoSupport {

	public void save(User user) {
		this.getJdbcTemplate().update("insert into kd_user values(null,?,?)",
				user.getUserName(), user.getPassword());
	}

	public void update(User user) {
		this.getJdbcTemplate().update(
				"update kd_user set username=?,password=? where user_id = ?",
				user.getUserName(), user.getPassword(), user.getUser_id());
	}

	public void delete(User user) {
		this.getJdbcTemplate().update("delete from kd_user where user_id = ?",
				user.getUser_id());
	}
}
